import 'package:flutter/material.dart';

class WFLongButton extends StatelessWidget {
	final String text;
	final VoidCallback onPressed;
	final Color bgColor;
	final Color textColor;
	final double textSize;
	final double height;
	final double roundedCornerRadius;
	
	WFLongButton(
		this.text,
		this.onPressed,
			{
		this.bgColor = const Color(0x33000000),
		this.textColor = Colors.white,
		this.textSize = 16.0,
		this.roundedCornerRadius = 4.0,
		this.height = 40.0});
	
	@override
	Widget build(BuildContext context) {
		return Container(
			child: Row(
				children: <Widget>[
					Expanded(
						child: SizedBox(
							height: height,
							child: TextButton(
								style: ButtonStyle(
										overlayColor: MaterialStateProperty.resolveWith((states) {
											return Colors.transparent;
										}),
										// foregroundColor: MaterialStateProperty.resolveWith(
										// 			(states) {
										// 		if (states.contains(MaterialState.focused) &&
										// 				!states.contains(MaterialState.pressed)) {
										// 			//获取焦点时的颜色
										// 			return Colors.blue;
										// 		} else if (states.contains(MaterialState.pressed)) {
										// 			//按下时的颜色
										// 			return Colors.deepPurple;
										// 		}
										// 		//默认状态使用灰色
										// 		return Colors.grey;
										// 	},
										// ),
										//背景颜色
										backgroundColor: MaterialStateProperty.resolveWith((states) {
											//设置按下时的背景颜色
											// if (states.contains(MaterialState.pressed)) {
											// 	// return Colors.blue[200];
											// 	return Colors.green;
											// }
											return bgColor;
										}),
									shape: MaterialStateProperty.all(StadiumBorder()),
								),
								child: Text(
									text,
									style: TextStyle(
											color: textColor,
											fontSize: textSize
									),
								),
								onPressed: onPressed,
							),
							// child: FlatButton(
							// 	onPressed: onPressed,
							// 	color: bgColor,
							// 	textColor: Colors.white,
							// 	shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(roundedCornerRadius)),
							// 	child: Text(
							// 		text,
							// 		style: TextStyle(
							// 			color: textColor,
							// 			fontSize: textSize
							// 		),
							// 	),
							// ),
						),
					),
				],
			),
		);
	}
}